package shuashuami.hb.com;

import android.content.Context;

import com.franmontiel.persistentcookiejar.ClearableCookieJar;
import com.mob.MobApplication;
import com.mob.MobSDK;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hufangda on 2017/7/16.
 */

public class Application extends MobApplication {

    private List<String> images;
    public void onCreate() {
        super.onCreate();
        images = new ArrayList<>();
        MobSDK.init(this, this.a(), this.b());
        initImageLoader(this);

    }





    public void addImages(String imgs) {
        images.add(imgs);
    }

    public List<String> getImages() {
        return images;
    }

    public void setImages(List<String> images) {
        this.images = images;
    }

    private void initImageLoader(Context context) {
        // This configuration tuning is custom. You can tune every option, you may tune some of them,
        // or you can create default configuration by
        //  ImageLoaderConfiguration.createDefault(this);
        // method.
        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(20 * 1024 * 1024); // 20 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.writeDebugLogs(); // Remove for release app
        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());
    }

    private ClearableCookieJar cookieJar;

    public void SetClearableCookieJar(ClearableCookieJar context) {
        this.cookieJar = context;
    }

    public ClearableCookieJar getClearableCookieJar() {
        return cookieJar;
    }
}
